package com.hpeng.sys.action;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.hpeng.util.Mytimerservice;
import com.opensymphony.xwork2.ActionSupport;

@Component("backupDataAction")
@Scope("prototype")
public class BackupDataAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private Mytimerservice mytimerservice = new Mytimerservice();
	private String msg;

	public String backupData() {
		String realPath = ServletActionContext.getServletContext().getRealPath("/");
		System.out.println(realPath);
		try {
		   String cmd = "cmd /c start "+realPath+"dbbackup/backupDB.bat";
		   mytimerservice.execute(cmd);
		} catch (Exception e) {
			msg = "数据库备份失败！请重试.";
		}
		if (msg == null || "".equals(msg.trim())){

		}
		return "success";
	}

	
	
	
	
	public Mytimerservice getMytimerservice() {
		return mytimerservice;
	}

	public void setMytimerservice(Mytimerservice mytimerservice) {
		this.mytimerservice = mytimerservice;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

}